package dreamCookGame;

public class Recipe {
	private String[] _ingredients;
	private String[] _bonusIngredients;
	private int[] _points;
	private int[] _bonus;
	private int _minScore;
	
	public Recipe(String[] ingredients){
		_ingredients = ingredients;
		_points = null;
		_minScore = 0;
	}
	public Recipe(String[] ingredients,String[] bonusIngredients){
		_ingredients = ingredients;
		_points = null;
		_minScore = 0;
		
		_bonusIngredients = bonusIngredients;
		_bonus = null;
	}
	public Recipe(String[] ingredients, int[] ingredientPoints, int minScore){
		_ingredients = ingredients;
		_points = ingredientPoints;
		_minScore = minScore;
		
		_bonusIngredients = ingredients;
		_bonus = ingredientPoints;
	}
	public Recipe(String[] ingredients, int[] ingredientPoints,String[] bonusIngredients, int[] bonusPoints, int minScore){
		_ingredients = ingredients;
		_points = ingredientPoints;
		_minScore = minScore;
		
		_bonusIngredients = bonusIngredients;
		_bonus = bonusPoints;
	}
	
	public boolean compareTo(Recipe recipe){
		/*
		int thisScore = 0;
		for(int i=0; i<_ingredients.length; i++){
			if(_ingredients[i].equalsIgnoreCase(recipe.getIngredient(i))){
				thisScore += recipe.getPoints(i);
			}
		}
		if(thisScore>=recipe.getMinScore()){
			return true;
		}else{
			return false;
		}*/
		
		int ingredientCount = 0;
		boolean returnValue = true;
		for(int i=0; i<_ingredients.length; i++){
			if((i<recipe.getRecipeLength())&&_ingredients[i].equalsIgnoreCase(recipe.getIngredient(i))){
				ingredientCount+=1;
			}else if((i<recipe.getBonusLength())&&_ingredients[i].equalsIgnoreCase(recipe.getBonusIngredient(i))){
				//do nothing
			}
			else returnValue = false;
		}
		
		if(returnValue){
			if(ingredientCount!=recipe.getRecipeLength()){
				returnValue=false;
			}
		}
		
		return returnValue;
	}

	/**
	 * 
	 * @param recipe
	 * @return score
	 * Do not use this method yet.  We'll need to decide to implement scoring first.
	 */
	public int scoreTo(Recipe recipe){
		//TODO: if we implement scoring, I will implement this method. -Jonathan
		int score=0;
		return score;
	}
	
	public void addIngredient(String ingredient){
		String[] tempArray = new String[_ingredients.length+1];
		for(int i=0;i<_ingredients.length;i++){
			tempArray[i]=_ingredients[i];
		}
		tempArray[_ingredients.length] = ingredient;
		_ingredients = tempArray;
	}
	
	public int getMinScore() {
		return _minScore;
	}
	public int getPoints(int index) {
		return _points[index];
	}
	public String getIngredient(int index) {
		return _ingredients[index];
	}
	public String getBonusIngredient(int index) {
		return _bonusIngredients[index];
	}
	public int getRecipeLength(){
		return _ingredients.length;
	}
	public int getBonusLength() {
		return _bonusIngredients.length;
	}
}